#ifndef __ANALYZER_H
#define __ANALYZER_H

#define MAX_SAMPLES (4096-1)

/* shooting for <= 2 HUB cycles ... will never happen with COGC */
#define HUBCYCLES 7
/* #define HUBCYCLES 5 // good for goat */
/* #define HUBCYCLES 7 // good for goto */

enum {
    MAX_RATE = (5000000/HUBCYCLES),
    MIN_RATE = (1)
}; 

extern int _load_start_analyzer_cog[];
extern int _load_stop_analyzer_cog[];

enum {
  CMD_IDLE = 0,
  CMD_GOAT,
  CMD_GOTO,
  CMD_LAST
};

typedef volatile struct Mailbox_struct
{
  int cmd;      /* Command to run */
  int last;     /* Last command ran */
  int pins;     /* Pins to sample */
  int arm;      /* Arm pin mask */
  int trig;     /* Trigger pin mask */
  int size;     /* Number of samples to take */
  int rate;     /* Rate of samples saved only for user */
  int delay;    /* Delay between samples used by collector cog */
  int *pos;     /* Pos is the end of collected data for GOAT or middle for GOTO */
  int wrap;     /* Set if data wrapped around the end of the buffer */
  int length;   /* length is the size of the buffer queue */
  int *qptr;    /* queue is data pointer managed by head/tail */
} Mailbox_t;

/*
 * This defines the structure which we'll pass to the C cog.
 */
typedef struct Par_struct 
{
    unsigned int stack[32]; /* Provide a small stack for the COG */
    Mailbox_t mailbox;      /* Provide a mailbox to communicate to the COG */
} PAR_t;

#endif
/* __ANALYZER_H */